import request from '@/utils/request'
import { ObjToQueryString } from '@/utils/method'
const baseUrl = process.env.VUE_APP_BASE_API
// 催收业务配置
export const getBusinessConfig = (params) => {
  return request({
    url: '/overdue/businessConfig/list',
    params,
    method: 'get'
  })
}
export const addBusinessConfig = (data) => {
  return request({
    url: '/overdue/businessConfig',
    data,
    method: 'post'
  })
}
export const updateBusinessConfig = (data) => {
  return request({
    url: '/overdue/businessConfig',
    data,
    method: 'put'
  })
}

// 催收数据总览
export const getStatement = (params) => {
  return request({
    url: '/overdueStatement/getStatement',
    params,
    method: 'get'
  })
}
export const exportStatement = (params) => {
  const url = '/overdueStatement/exportStatement'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}

// 催收案件管理
export const getAllOverdueStaff = (params) => {
  return request({
    url: '/overdueMembersManage/getAllOverdueStaff',
    params,
    method: 'get'
  })
}
export const queryOverdueOrder = (params) => {
  return request({
    url: '/overdueCaseManage/queryOverdueOrder',
    params,
    method: 'get'
  })
}
export const exportOverdueOrder = (params) => {
  const url = '/overdueCaseManage/exportOverdueOrder'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
export const getCurrentEmployeeStaffID = () => {
  return request({
    url: '/overdueMembersManage/getCurrentEmployeeStaffID',
    method: 'get'
  })
}

// 留存
export const setOverdueOrderKeep = (data) => {
  return request({
    url: '/overdueCaseManage/setOverdueOrderKeep',
    data,
    method: 'put'
  })
}
// 分配
export const allocate = (data) => {
  return request({
    url: '/overdueCaseManage/allocate',
    data,
    method: 'post'
  })
}
// 通话记录
export const queryOverdueCallRecord = (params) => {
  return request({
    url: '/overdueRecord/queryOverdueCallRecord',
    params,
    method: 'get'
  })
}
export const exportOverdueCallRecord = (params) => {
  const url = '/overdueRecord/queryOverdueCallRecord/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 短信记录
export const queryOverdueMessageRecord = (params) => {
  return request({
    url: '/overdueRecord/queryOverdueMessageRecord',
    params,
    method: 'get'
  })
}
export const exportOverdueMessageRecord = (params) => {
  const url = '/overdueRecord/queryOverdueMessageRecord/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 催收公司
export const getAllOverdueFirm = () => {
  return request({
    url: '/overdueMembersManage/getAllOverdueFirm',
    method: 'get'
  })
}
export const addOverdueFirm = (data) => {
  return request({
    url: '/overdueMembersManage/addOverdueFirm',
    data,
    method: 'post'
  })
}
export const queryOverdueFirm = (params) => {
  return request({
    url: '/overdueMembersManage/queryOverdueFirm',
    params,
    method: 'get'
  })
}
export const updateOverdueFirm = (data) => {
  return request({
    url: '/overdueMembersManage/updateOverdueFirm',
    data,
    method: 'post'
  })
}
// 催收小组
export const getAllOverdueGroup = () => {
  return request({
    url: '/overdueMembersManage/getAllOverdueGroup',
    method: 'get'
  })
}
export const addOverdueGroup = (data) => {
  return request({
    url: '/overdueMembersManage/addOverdueGroup',
    data,
    method: 'post'
  })
}
export const queryOverdueGroup = (params) => {
  return request({
    url: '/overdueMembersManage/queryOverdueGroup',
    params,
    method: 'get'
  })
}
export const updateOverdueGroup = (data) => {
  return request({
    url: '/overdueMembersManage/updateOverdueGroup',
    data,
    method: 'post'
  })
}
// 催收人员
export const addOverdueStaff = (data) => {
  return request({
    url: '/overdueMembersManage/addOverdueStaff',
    data,
    method: 'post'
  })
}
export const queryOverdueStaff = (params) => {
  return request({
    url: '/overdueMembersManage/queryOverdueStaff',
    params,
    method: 'get'
  })
}
export const updateOverdueStaff = (data) => {
  return request({
    url: '/overdueMembersManage/updateOverdueStaff',
    data,
    method: 'post'
  })
}
// 催收小组报表 - 累计
export const getUrgentRecallGroupStatementTotal = (params) => {
  return request({
    url: '/overdueStatement/getUrgentRecallGroupStatement/total',
    params,
    method: 'get'
  })
}
export const exportUrgentRecallGroupStatementTotal = (params) => {
  const url = '/overdueStatement/getUrgentRecallGroupStatement/total/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 催收小组报表 - 明细
export const getUrgentRecallGroupStatementDetail = (params) => {
  return request({
    url: '/overdueStatement/getUrgentRecallGroupStatement/detail',
    params,
    method: 'get'
  })
}
export const exportUrgentRecallGroupStatementDetail = (params) => {
  const url = '/overdueStatement/getUrgentRecallGroupStatement/detail/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 催收阶段报表
export const getOverdueReceivableStageStatement = (params) => {
  return request({
    url: '/overdueStatement/overdueReceivableStageStatement',
    params,
    method: 'get'
  })
}
export const exportOverdueReceivableStageStatement = (params) => {
  const url = '/overdueStatement/exportOverdueReceivableStageStatement'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 催回金额明细
export const urgentRecallAmountDetail = (params) => {
  return request({
    url: '/overdueRecord/urgentRecallAmountDetail',
    params,
    method: 'get'
  })
}
// 催回金额明细 导出
export const exportUrgentRecallAmountDetail = (params) => {
  const url = '/overdueRecord/urgentRecallAmountDetail/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 催收日志
export const listUrgentRecallLog = (params) => {
  return request({
    url: '/overdueRecord/listUrgentRecallLog',
    params,
    method: 'get'
  })
}
// 催收日志导出
export const exportListUrgentRecallLog = (params) => {
  const url = '/overdueRecord/listUrgentRecallLog'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 获取工作台统计数据
export const getAdminReport = (userId) => {
  return request({
    url: `/urgentRecall/getAdminReport/${userId}`,
    method: 'get'
  })
}
// 获取工作台催收订单列表
export const queryOverdueOrderInWorkbench = (params) => {
  return request({
    url: '/overdueCaseManage/queryOverdueOrderInWorkbench',
    params,
    method: 'get'
  })
}
// 导出工作台催收订单列表
export const exportOverdueOrderInWorkbench = (params) => {
  const url = '/overdueCaseManage/exportOverdueOrderInWorkbench'
  if (params) {
    const data = ObjToQueryString(params)
    window.location.href = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location.href = baseUrl + url
  }
}
// 获取消息提醒列表
export const getRemindList = (userId) => {
  return request({
    url: `/urgentRecall/queryRemindRecordByParam/${userId}`,
    method: 'get'
  })
}
// 更新消息提醒列表
export const updateRemind = (data) => {
  return request({
    url: '/urgentRecall/batchUpdateRemindRecordByParam',
    data,
    method: 'put'
  })
}
// 查询案件流转记录
export const queryFlowHistory = (params, orderId) => {
  return request({
    url: `/urgentRecall/queryFlowHistory/${orderId}`,
    params,
    method: 'get'
  })
}
